#!/usr/bin/env python

from pymol import cmd

cmd.load('out.pdb')
cmd.turn('y',90)
cmd.select('lj2','name LJ2')
cmd.set('sphere_scale',6,'all')
cmd.show('spheres')
cmd.set('orthoscopic','on')
cmd.hide('everything','all')
cmd.show('spheres','all')
cmd.bg_color('white')
cmd.set('ray_trace_frames',1)
cmd.move('z','1000')

import numpy as np
#check if phase information was loaded before...
if not 'phaseData' in globals():
  print "loading phase information..."
  #phaseData = np.loadtxt('phase.txt')
  phaseData = np.loadtxt('d.txt')
  print "...done!"

#nat = cmd.count_atoms()
cmd.alter("all","b = phaseData[ID-1,1]")

cmd.hide("all")
cmd.show("spheres")
cmd.spectrum("b","blue_white_red", "all","0",'1')
#cmd.select("liq","b<1")
cmd.select("liq","b<0.7 & not lj2")
cmd.color('blue','liq')
cmd.set('sphere_transparency','0.3','liq')
cmd.color('red','lj2')
cmd.set('sphere_scale',18,'lj2')
cmd.select('ice','b>0.7 & not lj2') 
cmd.set('sphere_scale',12,'ice')
cmd.color('marine','ice')
#low quali
cmd.viewport('1280','380')
cmd.ray()
cmd.png('snapshot-low.png')
#high quali
#cmd.viewport('5120','1520')
#cmd.ray()
#cmd.png('snapshot-high.png')
